package com.dm.entity;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * @author hqw521@qq.com
 * @date 2018/11/12 20:35
 */
@Entity
@Table(name = "dm_file", schema = "dm", catalog = "")
public class File {
    private int fileId;
    private String fileName;
    private String fileTheme;
    private String fileKeyWord;
    private Integer folderId;
    private Integer clickNumber;
    private Integer userId;
    private Timestamp createTime;
    private Timestamp updateTime;
    private Folder dmFolderByFolderId;
    private User dmUserByUserId;
    private String filePath;
    private String relativePath;
    private Double fileSize;
    private Collection<Record> dmRecordsByFileId;

    @Id
    @Column(name = "file_id", nullable = false)
    public int getFileId() {
        return fileId;
    }

    public void setFileId(int fileId) {
        this.fileId = fileId;
    }

    @Basic
    @Column(name = "file_name", nullable = false, length = 20)
    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    @Basic
    @Column(name = "file_theme", nullable = true, length = 20)
    public String getFileTheme() {
        return fileTheme;
    }

    public void setFileTheme(String fileTheme) {
        this.fileTheme = fileTheme;
    }

    @Basic
    @Column(name = "file_keyWord", nullable = true, length = 50)
    public String getFileKeyWord() {
        return fileKeyWord;
    }

    public void setFileKeyWord(String fileKeyWord) {
        this.fileKeyWord = fileKeyWord;
    }

    @Basic
    @Column(name = "folder_id", nullable = true)
    public Integer getFolderId() {
        return folderId;
    }

    public void setFolderId(Integer folderId) {
        this.folderId = folderId;
    }

    @Basic
    @Column(name = "click_number", nullable = true)
    public Integer getClickNumber() {
        return clickNumber;
    }

    public void setClickNumber(Integer clickNumber) {
        this.clickNumber = clickNumber;
    }

    @Basic
    @Column(name = "user_id", nullable = true)
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "file_path", nullable = true)
    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    @Basic
    @Column(name = "relative_path", nullable = true)
    public String getRelativePath() {
        return relativePath;
    }

    public void setRelativePath(String relativePath) {
        this.relativePath = relativePath;
    }

    @Basic
    @Column(name = "file_size", nullable = true)
    public Double getFileSize() {
        return fileSize;
    }

    public void setFileSize(Double fileSize) {
        this.fileSize = fileSize;
    }

    @Basic
    @Column(name = "create_time", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time", nullable = true)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @ManyToOne
    @JoinColumn(name = "folder_id", referencedColumnName = "folder_id", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    public Folder getDmFolderByFolderId() {
        return dmFolderByFolderId;
    }

    public void setDmFolderByFolderId(Folder dmFolderByFolderId) {
        this.dmFolderByFolderId = dmFolderByFolderId;
    }

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    public User getDmUserByUserId() {
        return dmUserByUserId;
    }

    public void setDmUserByUserId(User dmUserByUserId) {
        this.dmUserByUserId = dmUserByUserId;
    }

    @OneToMany(mappedBy = "dmFileByFileId")
    public Collection<Record> getDmRecordsByFileId() {
        return dmRecordsByFileId;
    }

    public void setDmRecordsByFileId(Collection<Record> dmRecordsByFileId) {
        this.dmRecordsByFileId = dmRecordsByFileId;
    }
}
